package com.code.qgjx.service.impl;

import com.code.qgjx.entity.JobPosition;
import com.code.qgjx.mapper.JobPositionMapper;
import com.code.qgjx.service.JobPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class JobPositionServiceImpl implements JobPositionService {
    
    @Autowired
    private JobPositionMapper jobPositionMapper;
    
    @Override
    public List<JobPosition> getJobList(String keyword, int offset, int limit,String status) {
        return jobPositionMapper.selectList(keyword, offset, limit,status);
    }
    @Override
    public List<JobPosition> getJobListByUser(String keyword, int offset, int limit,String user) {
        return jobPositionMapper.selectListByUser(keyword, offset,user, limit);
    }
    
    @Override
    public int getJobCount(String keyword,String status) {
        return jobPositionMapper.selectCount(keyword,status);
    }

    @Override
    public int getJobCountByUser(String user) {
        return jobPositionMapper.selectCountByUser(user);
    }

    @Override
    public JobPosition getJobDetail(Integer id) {
        return jobPositionMapper.selectById(id);
    }
    
    @Override
    public boolean approveJob(Integer id, String updatedBy) {
        return jobPositionMapper.updateStatus(id, "已通过", null, updatedBy) > 0;
    }
    
    @Override
    public boolean rejectJob(Integer id, String rejectReason, String updatedBy) {
        return jobPositionMapper.updateStatus(id, "已驳回", rejectReason, updatedBy) > 0;
    }
    
    @Override
    public boolean addJob(JobPosition jobPosition) {
        return jobPositionMapper.insert(jobPosition) > 0;
    }

    @Override
    public List<JobPosition> getJobPositionsByUserId(Long userId) {
        return jobPositionMapper.findByUserId(userId);
    }
} 